/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPnlFinalSignal.java
 *
 * Created on 07/03/2010, 22:50:03
 */
package systole.view.tabs;

import systole.view.tabs.finalsegment.JPnlResults;
import java.awt.CardLayout;
import systole.view.charts.XYChart;
import systole.view.tabs.controllers.AnalysisController;
import systole.view.tabs.finalsegment.JPnlEmpty;
import systole.view.tabs.finalsegment.JpnlFinalDerivatives;
import systole.view.tabs.finalsegment.JpnlFinalOverlayed;
import systole.view.tabs.finalsegment.JpnlFinalParams;
import systole.view.tabs.finalsegment.JpnlFinalSegment;
import systole.view.tabs.finalsegment.JpnlFinalSummary;

/**
 *
 * @author jmj
 */
public class JPnlFinalSignal extends javax.swing.JPanel {

    /**
     *
     */
    private static final long serialVersionUID = 8072513301878351172L;
    private AnalysisController analysisControl;
    private JpnlFinalDerivatives derivativesPnl;
    private JpnlFinalSegment meansegmentPnl;
    private JpnlFinalParams paramsPnl;
    private JpnlFinalSummary summaryPnl;
    private JpnlFinalOverlayed overlayedPnl;
    private JPnlEmpty empty;
    private JPnlResults resultsPnl;

    /** Creates new form JPnlFinalSignal
     * @param logic
     */
    public JPnlFinalSignal(AnalysisController logic) {       
        initComponents();
        this.analysisControl = logic;
        //Summary creation
        this.resultsPnl = new JPnlResults();
        analysisControl.getResultsModel().addObserver(resultsPnl);
        this.summaryPnl = new JpnlFinalSummary(resultsPnl);
        //OverlayedSegments creation
        this.overlayedPnl = new JpnlFinalOverlayed();
        //final segment creation
        this.meansegmentPnl = new JpnlFinalSegment();
        //derivatives creation
        this.derivativesPnl = new JpnlFinalDerivatives();
        //parameters creation
        this.paramsPnl = new JpnlFinalParams(this.analysisControl);
        // empty panel
        this.empty = new JPnlEmpty();
        //Adding to cardlayout
        this.add(this.summaryPnl, "Summary");
        this.add(this.overlayedPnl, "Overlayed");
        this.add(this.meansegmentPnl, "FinalSegment");
        this.add(this.derivativesPnl, "Derivatives");
        this.add(this.paramsPnl, "Params");
        this.add(this.empty, "Empty");
        this.showEmptyPanel();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setName("Form"); // NOI18N
        setLayout(new java.awt.CardLayout());
    }// </editor-fold>//GEN-END:initComponents

    public void loadPanels(XYChart overlayedSegments, XYChart finalSegment, XYChart derivatives) {
        this.summaryPnl.loadSummary(overlayedSegments, finalSegment, derivatives);
        this.overlayedPnl.loadSegments(overlayedSegments);
        this.meansegmentPnl.loadSegment(finalSegment);
        this.derivativesPnl.loadDerivatives(derivatives);
        this.paramsPnl.loadSegments();
        this.showPanel("Summary");
    }

    /**
     * @return the derivativesPnl
     */
    public JpnlFinalDerivatives getDerivativesPnl() {
        return derivativesPnl;
    }

    /**
     * @param derivativesPnl the derivativesPnl to set
     */
    public void setDerivativesPnl(JpnlFinalDerivatives derivativesPnl) {
        this.derivativesPnl = derivativesPnl;
    }

    /**
     * @return the meansegmentPnl
     */
    public JpnlFinalSegment getMeansegmentPnl() {
        return meansegmentPnl;
    }

    /**
     * @param meansegmentPnl the meansegmentPnl to set
     */
    public void setMeansegmentPnl(JpnlFinalSegment meansegmentPnl) {
        this.meansegmentPnl = meansegmentPnl;
    }

    /**
     * @return the paramsPnl
     */
    public JpnlFinalParams getParamsPnl() {
        return paramsPnl;
    }

    /**
     * @param paramsPnl the paramsPnl to set
     */
    public void setParamsPnl(JpnlFinalParams paramsPnl) {
        this.paramsPnl = paramsPnl;
    }

    /**
     * @return the summaryPnl
     */
    public JpnlFinalSummary getSummaryPnl() {
        return summaryPnl;
    }

    /**
     * @param summaryPnl the summaryPnl to set
     */
    public void setSummaryPnl(JpnlFinalSummary summaryPnl) {
        this.summaryPnl = summaryPnl;
    }

    /**
     * @param constraint
     */
    public void showPanel(String constraint) {

        CardLayout cl = (CardLayout) this.getLayout();
        cl.show(this, constraint);
        this.revalidate();
    }

    public void showEmptyPanel(){
        this.showPanel("Empty");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
